package com.one.blocks.rbac.manager;

import com.one.blocks.mvc.manager.AbstractBatchManager;
import com.one.blocks.rbac.domain.SysRoleMenu;
import com.one.blocks.rbac.mapper.SysRoleMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author <a href="mailto:idler41@163.con">idler41</a> created on 2022-02-14 13:57:56
 */
@Service
public class SysRoleMenuManager extends AbstractBatchManager<SysRoleMenuMapper, SysRoleMenu> {

    @Autowired
    public SysRoleMenuManager(SysRoleMenuMapper mapper) {
        super(mapper);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteByRoleId(Integer roleId) {
        mapper.deleteByRoleId(roleId);
    }

    public Integer findOneByMenuIds(Integer[] menuIds) {
        return mapper.selectOneByMenuIds(menuIds);
    }

    public Integer findOneByRoleIds(Integer... roleIds) {
        return mapper.selectOneByRoleIds(roleIds);
    }
}